from django.http import HttpResponse
from django.utils.decorators import method_decorator
from django.views.generic import View


def my_dec(func):

    def inner(request,*args,**kwargs):

        print("这是一个装饰器")

        print("请求路径是：%s"%request.path)

        return func(request,*args,**kwargs)

    return inner

# @method_decorator(my_dec,name='get')
# @method_decorator(my_dec,name='post')
# @method_decorator(my_dec,name='dispatch')

class OneMixin(object):

    @classmethod
    def as_view(cls,*args,**kwargs):

        view = super().as_view(*args,**kwargs)
        view = my_dec(view)

        return view


class TwoMixin(object):

    @classmethod
    def as_view(cls,*args,**kwargs):

        view = super().as_view(*args,**kwargs)
        view = my_dec(view)

        return view




class DemoView(OneMixin,TwoMixin,View):

    def get(self,request):

        print("DemoView get方法")

        return HttpResponse("DemoView get方法")

    def post(self, request):

        print("DemoView post方法")

        return HttpResponse("DemoView post方法")



